-- This script was generated by the Schema Diff utility in pgAdmin 4
-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
-- and may require manual changes to the script to ensure changes are applied in the correct order.
-- Please report an issue for any failure with the reproduction steps.

CREATE OR REPLACE FUNCTION public.date_count(
	time_increment text,
	prev_period text)
    RETURNS SETOF record 
    LANGUAGE 'sql'
    COST 100
    VOLATILE PARALLEL UNSAFE
    ROWS 1000

AS $BODY$
   select DATE_TRUNC(time_increment, created_at) as created_at_trunc, COUNT(*) from request group by DATE_TRUNC(time_increment, created_at) having DATE_TRUNC(time_increment, created_at) >= CAST(prev_period AS TIMESTAMP) order by created_at_trunc
$BODY$;

ALTER FUNCTION public.date_count(text, text)
    OWNER TO postgres;

GRANT EXECUTE ON FUNCTION public.date_count(text, text) TO PUBLIC;

GRANT EXECUTE ON FUNCTION public.date_count(text, text) TO anon;

GRANT EXECUTE ON FUNCTION public.date_count(text, text) TO authenticated;

GRANT EXECUTE ON FUNCTION public.date_count(text, text) TO postgres;

GRANT EXECUTE ON FUNCTION public.date_count(text, text) TO service_role;
